###########################################################################
#
#   Copyright 2010 American Public Media Group
#
#   This file is part of AIR2.
#
#   AIR2 is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   AIR2 is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with AIR2.  If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################

package AIR2::Searcher::Responses;
use strict;
use warnings;
use base qw( AIR2::Searcher );
use Carp;
use Data::Dump qw( dump );
use AIR2::Config;

sub config {
    return {
        index         => AIR2::Config->get_search_index_path('responses'),
        default_field => 'responseset',
        facet_names   => [
            qw(
                org_uuid
                tag
                inq_uuid_title
                prj_uuid_title
                )
        ],
        fields => {
            1 => { alias_for => [qw( XXX )] },

        },
    };
}

sub engine_class {'+AIR2::Searcher::Responses::Engine'}
sub authz_field  {'responseset.authz'}

my @no_hilite = qw(
    sact_org_id

);

sub no_hilite { return \@no_hilite }

sub snipper_config {
    return {
        occur         => 2,      # number of snips
        context       => 100,    # number of words in each snip
        as_sentences  => 1,
        ignore_length => 1,      # ignore max_chars, return entire snippet.
        show          => 0,      # only show if match, no dumb substr
        treat_phrases_as_singles => 0,    # keep phrases together
    };
}

sub get_authz_string {
    my ( $self, $org_masks ) = @_;
    my $str = $self->SUPER::get_authz_string($org_masks);
    $str = "($str OR prj_shared_flag=1)";
    return $str;
}

1;
